package com.sky.task;

import com.sky.websocket.WebSocketServer;
import lombok.extern.slf4j.Slf4j;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.scheduling.annotation.Scheduled;
import org.springframework.stereotype.Component;

/**
 * 我的任务
 *
 * @author liudo
 * @version 1.0
 * @project sky-take-out
 * @date 2023/12/15 09:21:14
 */
@Slf4j
// @Component
public class MyTask {

    @Autowired
    private WebSocketServer webSocketServer;

    /**
     * 要求每秒钟执行一次
     */
    @Scheduled(cron = "*/1 * * * * *")
    public void hello() {
        webSocketServer.sendToAllClient("这是服务端主动推送的消息");
    }

}
